package com.lu.servlet;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.lu.domain.SysOperateLog;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
public class LogFitter  extends MethodFilterInterceptor {
	
	private static final long serialVersionUID = 1L;

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		String action = invocation.getInvocationContext().getName();	
		Map<String, Object> session = invocation.getInvocationContext().getSession();
		boolean isEmpty = session.isEmpty();
		
		if(isEmpty || !session.containsKey("sysUser"))
			return invocation.invoke();

//		if(!ActionMapper.getMapper().containsKey(action)) 
//			return invocation.invoke();
		
		
		HttpServletRequest request = ServletActionContext.getRequest();
		SysOperateLog mainLog = setLogMap(session, request, action);
		
		if(null != mainLog){
			log(mainLog);
		}

		return invocation.invoke();
	}
	
	private SysOperateLog setLogMap(Map<String, Object> session, HttpServletRequest request, String action ){
		return null;
	}
	private boolean log(SysOperateLog mainLog){
		return true;
	}
	
}